'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 军功排行 
 * @author sundbcn@gmail.com (sun debing)
 */

var async = require('async');
var Code = require('../../../../consts/code');
var honorRankService = require('../../../../services/honorRankService');

module.exports = function (msg, session, next) {
    var role_id = session.uid;

    var current_role_info;
    var top_fifty_role;
    async.series(
        [
            function (cb) {
                honorRankService.getCurrentRoleRank(role_id, function (err, result) {
                    current_role_info = result;
                    cb();
                });
            },
            function (cb) {
                honorRankService.getHonorRank(function (err, result) {
                    top_fifty_role = result;
                    cb();
                });
            }
        ],
        function (err) {
            if (!!err) {
                console.error(err);
                return next(null, {
                    code: Code.FAIL
                });
            }
            return next(null, {
                code: Code.OK,
                result: {
                    current_role_info: current_role_info,
                    top_fifty_role: top_fifty_role
                }
            });
        }
    );
};
